-
Notifications
You must be signed in to change notification settings - Fork 1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Derived fields should respect causality region + Improve tests #5488
Conversation
78d9467
to
dbd7a64
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cool that we can do a test with a blockchain!
|
||
const ONCHAIN_FROM_OFFCHAIN = "CREATE_ONCHAIN_DATASOURCE_FROM_OFFCHAIN_HANDLER"; | ||
const CREATE_FILE = "CREATE_FILE"; | ||
// const CREATE_FILE_FROM_HANDLE_FILE = "CREATE_FILE_FROM_HANDLE_FILE"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe remove it, if its not used.
@@ -90,6 +90,7 @@ impl DerivedEntityQuery { | |||
/// Checks if a given key and entity match this query. | |||
pub fn matches(&self, key: &EntityKey, entity: &Entity) -> bool { | |||
key.entity_type == self.entity_type | |||
&& key.causality_region == self.causality_region |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love short implementations!
let hash = context.getString("hash"); | ||
log.info("Creating file data source from handleFile: {}", [hash]); | ||
dataSource.createWithContext("File", [hash], new DataSourceContext()); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what's idiomatic for TypeScript bu wouldn't else if
look more like a switch statement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agree, it should have been an else if.
We cannot use switch cases though since switch-case in assemblyscript does not work with string
AssemblyScript/assemblyscript#1643
entity.content = data.toString(); | ||
entity.save(); | ||
} | ||
} else { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can remove a nesting level by doing this block if not command and returning. Then you know all the rest are commands. as zoran said it's prolly more of a switch case, mostly for making it a bit easier to maintain and read if you think it's worth. But also none of the ifs return when match so that could create some weird test situations 😆
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed, making the change.
96a3d38
to
c0b4cb0
Compare
Closes #5267